home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_oth / fifth21 / fifth.doc < prev    next >
Text File  |  1986-04-26  |  19KB  |  401 lines

  1.  
  2.  
  3.                           A Quick Look At Fifth
  4.                           - ----- ---- -- -----
  5.  
  6.  
  7.                        -- The Philosophy of Fifth --
  8.  
  9.      Fifth   is   first  and  foremost  a   programmer's   programming
  10.      environment.  Fifth  is made up of a compiler,  a text editor,  a
  11.      dictionary editor, and an interactive environment. These elements
  12.      are   highly   integrated  to  produce  the   Fifth   programming
  13.      environment.
  14.  
  15.      Fifth as a language is very simple and very flexible.  Fifth does
  16.      not  attempt to provide every structure a programmer might  want.
  17.      Instead,  Fifth  gives  the programmer the tools  to  create  any
  18.      structure he/she needs at compile time, easily and efficiently.
  19.  
  20.      The  main  goal of Fifth is to eliminate the  long  edit-compile-
  21.      debug times typical of compiled languages.  This cycle is reduced
  22.      in several ways:
  23.  
  24.      1)   Incremental Compilation.   Fifth limits compiles to sections
  25.           of code which have been changed, as they are changed, rather
  26.           than requiring a recompilation of the entire program.
  27.  
  28.      2)   Efficient Use of Primary Memory.  The entire Fifth system is
  29.           very  small  and thus can remain in primary  memory  at  all
  30.           times.   (Any portion of the system that is not required may
  31.           be removed by the programmer to further reduce size.)
  32.  
  33.      3)   Fast  Compilation.  The  Fifth compiler is  extremely  fast;
  34.           Fifth  code  compiles  an  order of  magnitude  faster  than
  35.           conventional compilers.
  36.  
  37.      4)   Minimal Bookkeeping.   The basis behind Fifth is very simple
  38.           and natural.  The programmer spends very little time keeping
  39.           books.
  40.  
  41.  
  42.                         -- Programming in Fifth --
  43.  
  44.      Fifth has an extremely simple syntax. There are only two distinct
  45.      syntactic constructs in Fifth:   modules and numbers. modules and
  46.      numbers must be separated by whitespace (blanks,  tabs,  carriage
  47.      returns,  linefeeds,  or  nulls).   Thus  the only  syntax  error
  48.      possible is that of an invalid module or number.
  49.  
  50.      Programs  are  written  in  Fifth by writing  modules  using  the
  51.      primitive  modules  (the modules that come with the  system)  and
  52.      other  user  defined  modules.  All modules are kept  in  a  tree
  53.      structured  dictionary which defines the scoping of the  modules.
  54.      Both modules and the dictionary can be easily  modified;  Modules
  55.      are altered using the module editor, and the dictionary using the
  56.      dictionary editor.
  57.  
  58.      But  what is a module?  A Fifth module is like a subroutine or  a
  59.      procedure in other languages.   But it is more.  A module is made
  60.      up of four parts:
  61.  
  62.      1)   The  module name,  which is used to reference the module.  A
  63.           name is made up of any combination of characters other  than
  64.           whitespace (Carriage returns, line feeds, nulls, blanks, and
  65.           tabs).
  66.  
  67.      2)   The source code which defines the module,
  68.  
  69.      3)   The  executable  code which the compiler produces  from  the
  70.           source code,
  71.  
  72.      4)   And a subdictionary which may contain submodules used in the
  73.           module's definition.
  74.  
  75.      Numbers  are combinations of digits and characters such that  the
  76.      same  combination  does  not exist in  the  dictionary,  and  all
  77.      characters are less than the current radix.  There are two  types
  78.      of numbers,  integers and reals. If the number contains a decimal
  79.      or exponent, it's real; otherwise it's integer.  Single precision
  80.      numbers  are in the range -2,147,483,648 to 2,147,483,647 and are
  81.      4 bytes long. The real numbers are also 32 bits. The precision is
  82.      approximately 7 significant digits, and the exponent range is -38
  83.      to +37.
  84.  
  85.  
  86.                            -- The Dictionary --
  87.  
  88.      Fifth's dictionary is an ideal data structure for programs.  Both
  89.      user  defined  modules and primitive modules (modules  that  come
  90.      with the system) are contained in this structure.  The source  or
  91.      text  code  for all modules is also kept in the  dictionary.  The
  92.      scoping of a program is expressed directly in the dictionary, and
  93.      can  be  easily examined and/or changed by using  the  dictionary
  94.      editor.  Thus  what modules are accessible by a module  is  under
  95.      programmer control through the Fifth programming environment.
  96.  
  97.      The  Fifth  dictionary  is hierarchical;   every  module  owns  a
  98.      subdictionary  and  belongs to another  subdictionary,  with  the
  99.      exception   of   the   root  module  which   owns   the   highest
  100.      subdictionary.  The owner of a particular subdictionary is called
  101.      the local module of that subdictionary.   The local module is the
  102.      only  module that has access its subdictionary.  Thus a module in
  103.      Fifth  can  be  broken down  into  smaller  logical  parts,  tied
  104.      together  by a main module,  with all the parts in placed in  the
  105.      main module's subdictionary.  When the main module is moved about
  106.      in  the dictionary,  the subdictionary and all modules within the
  107.      subdictionary are moved too.
  108.  
  109.      Thus  programs  in Fifth are written by building up modules  from
  110.      the primitive modules.  Program development becomes a process  of
  111.      writing  modules,   testing  them,   moving  them  about  in  the
  112.      dictionary,  and  using  the new modules to write other  modules.
  113.      Thus  elements  of  a program (modules) are  modified  using  the
  114.      module editor.   The structure of the program is edited using the
  115.      dictionary editor.   This division is very natural, and the Fifth
  116.      programming environment makes it easy.
  117.  
  118.  
  119.                             -- Scoping Rules --
  120.  
  121.      In  general,  scoping  is  a  term used  to  describe  what  what
  122.      programming  structures  can  or can not  be  accessed  from  any
  123.      position in a program.   Many languages use global scoping, which
  124.      means  that  all  subprograms or routines can  access  all  other
  125.      subprograms  or  routines.   In  large programs (and  even  small
  126.      programs) this can lead to problems.
  127.  
  128.      Fifth uses scoping rules that are similar to Pascal's.  In Fifth,
  129.      scoping is defined by a module's position in the dictionary. This
  130.      section  discusses  how  the  dictionary is used  to  define  the
  131.      scoping of a program.
  132.  
  133.      Each module in Fifth contains a subdictionary,  which is simply a
  134.      list of other modules.  (This list can be empty.) The modules  in
  135.      the subdictionary are available only to the local module,  and no
  136.      other module outside the subdictionary.
  137.  
  138.      When a module is is used in a definition, the module's definition
  139.      is needed.  The Fifth system attempts to find the module by doing
  140.      a  name  search  in  the dictionary.  The search  starts  in  the
  141.      subdictionary of the module being defined.  If the definition  is
  142.      not found,  successively higher subdictionaries are searched,  up
  143.      to the root module,  which is local to the highest subdictionary.
  144.      If no definition is found for the module,  (and the module is not
  145.      a valid number) it is considered undefined.  That is,  the module
  146.      may  exist  somewhere  in  the  dictionary,   but  is  considered
  147.      undefined if it is not in the search path.
  148.  
  149.  
  150.                  FIFTH
  151.                    |
  152.                    |
  153.                  { A  B  C }
  154.                    |  |  |
  155.                    |  |  +--------------------------+
  156.                    |  +------------+                |
  157.                    |               |                |
  158.                  { D  E  F }     { G  H  I }      { J  K }
  159.                                    |     |             |
  160.                                    |     +--+          |
  161.                                    |        |          |
  162.                                  { L }    { M  N }   { O  P }
  163.  
  164.                                 Figure 1.1
  165.  
  166.  
  167.      For example,  suppose the dictionary looked something like figure
  168.      1.1.   The  dictionary  search  starts  with  the  lowest  module
  169.      accessible from the local module,  and proceeds to the left, then
  170.      upward,  until the root module is reached.  The search NEVER goes
  171.      down,  nor to the right.  Suppose that {M} in figure 1.1 attempts
  172.      to  use  the  undefined module {X}.  The modules  examined  while
  173.      searching for {X} are,  in order:  {M},  {I}, {H}, {G}, {B}, {A},
  174.      and  {FIFTH}.  In  this case M is the lowest  accessible  module,
  175.      since  {M}'s  subdictionary  is  empty.   But  suppose  that  {K}
  176.      attempted to use {A}. This time the search path is {P}, {O}, {K},
  177.      {J},  {C},  {B},  and {A}.  Notice had we been searching for {M},
  178.      with {K} as the local module, {M} would be considered undefined.
  179.  
  180.      About the easiest way to learn the Fifth system is to jump on and
  181.      start using it.   Fifth places a high priority on  speed,  power,
  182.      and  flexibility,  but it is very easy to use and learn.  As  you
  183.      read through the manual,  try out the examples.   As quick as you
  184.      can,  write programs.  You will find that using bit and pieces of
  185.      the  supplied  programs quite easy and useful.
  186.  
  187.  
  188.                         -- The Dictionary Editor --
  189.  
  190.      The  dictionary  editor  allows the programmer  to  edit  Fifth's
  191.      dictionary. The following is a bit of terminology which will make
  192.      explanation of the dictionary editor and its use easier.
  193.  
  194.  
  195.                              -- Terminology --
  196.  
  197.      Before the dictionary is altered by the programmer,  it has  only
  198.      the  root  module,  and its subdictionary.   The root  module  is
  199.      originally  called {FIFTH},  and the root module's  subdictionary
  200.      holds only the primitive modules.
  201.  
  202.      (  Primitive  modules  are  all those  modules  basic  to  Fifth.
  203.      Primitives  differ  from user defined modules in that  they  come
  204.      with the system, and do not have subdictionaries of their own.)
  205.  
  206.      When  the  programmer  brings up the Fifth system for  the  first
  207.      time,  {FIFTH},  the root module,  becomes the local module.  The
  208.      text for the local module may be edited and compiled.  Submodules
  209.      may be created, deleted, renamed, and moved in the local module's
  210.      subdictionary.
  211.  
  212.      A submodule may be inspected,  in which case it becomes the local
  213.      module,  complete with its own subdictionary.   The local  module
  214.      may  be  exited,  in  which case the parent  module  (The  module
  215.      "above") again becomes the local module.
  216.  
  217.      The  local  module  specifies what modules are visible  from  the
  218.      interactive environment.  The interactive environment has  access
  219.      to  a  module if and only if the local module has access to  that
  220.      module.   Thus the interactive mode is an excellent place to test
  221.      modules and their interactions.  As a reminder, the prompt in the
  222.      interactive  mode  is  made up of the name of  the  local  module
  223.      followed  by a '>' symbol.  Thus if {FIFTH} is the local  module,
  224.      the prompt in the interactive mode will be:
  225.  
  226.              FIFTH>
  227.  
  228.      The  behavior  of the interactive mode is much the same  as  most
  229.      other FORTH systems.   Any sequence of modules may be entered and
  230.      executed.   New modules may be defined,  the local module may  be
  231.      redefined, etc.
  232.  
  233.      The  dictionary  editor is invoked by entering the  module  {DIR}
  234.      form the interactive environment.  It displays all the modules in
  235.      the  local  dictionary (The subdictionary of the  local  module).
  236.      Modules  in  the local dictionary may be selected with the  right
  237.      and  left  arrows.  When a module is selected,  it  is  shown  in
  238.      reverse video.   The local module appears in reverse video in the
  239.      top left hand corner of the screen.   Also shown are status flags
  240.      for the local module.  These are summarized in figure(3.1)
  241.  
  242.  
  243.      Flags - bits 0-F
  244.              0 - This link contains a valid entry
  245.              1 - Primitive module, no subdictionary,
  246.                     never needs compilation
  247.                     and has no text.
  248.              2 - Not compiled.  This module failed
  249.                     compilation for some reason.
  250.              3 - No text.  This module was created
  251.                     from the interactive environment,
  252.                     or has had its text striped off.
  253.                     This module cannot be recompiled.
  254.              4 - Header created by text, used while
  255.                     compiling from text.
  256.              5 - Suitable for inline coding.
  257.              6 - Immediate module.
  258.              7 - Compiler only module.
  259.              8 - Trace mode on.
  260.              9 - This module has 8087 alternate code
  261.                     in the parameter field.
  262.  
  263.                       Figure 3.1
  264.  
  265.  
  266.      The  following  is a list of keys and the functions  they  invoke
  267.      while in the dictionary editor.
  268.  
  269.      Left/right arrow - Selects a module.
  270.  
  271.      Up arrow - raises to the parent dictionary,  up to the root.   If
  272.           the root module is the local module, this key does nothing.
  273.  
  274.      Down arrow   - lowers  into  the  dictionary  of   the   selected
  275.           submodule.
  276.  
  277.      Ctrl left/right  (IBM PC) or shifted left/right arrows (TI PC)  -
  278.           move  the  selected submodule left or right.   This  feature
  279.           allows the submodules to be re-ordered.
  280.  
  281.      Ctrl page up  (IBM PC)  or shifted up arrow  (TI PC)  -  move the
  282.           selected  submodule  up in the  dictionary,  after the local
  283.           module in the subdictionary of the submodule previous to it.
  284.  
  285.      Ctrl page down (IBM PC) or shifted down arrow (TI  PC) - move the
  286.           selected  submodule  into  the dictionary of  the  submodule
  287.           previous to it,  moving the submodule farther from the  ROOT
  288.           dictionary.
  289.  
  290.      ESC - return to the interactive mode.
  291.  
  292.      C - compiles the local module.  Compiler errors are possible.  If
  293.           the compiler finds an error,  an error message is displayed,
  294.           and Fifth returns to the interactive mode.
  295.  
  296.      Del or  D  - deletes  the  selected submodule  and  all  of  it's
  297.           subdictionaries.  All submodules after the deleted submodule
  298.           are marked as not compiled.
  299.  
  300.      E- edits the text of the local module.  See module Editor.
  301.  
  302.      Ins or  I - allows a new submodule to be created in front of  the
  303.           selected submodule, or the local module to be (re)created.
  304.  
  305.      G - Executes  the  local module as if typed from the  interactive
  306.           environment.  Note  that  G provides no  method  of  placing
  307.           values  on the stack,  thus routines expecting values on the
  308.           stack will not execute properly in most cases.
  309.  
  310.      L - redirects  the  input  stream to the  specified  file.   This
  311.           allows any text file to become input to Fifth.   Text loaded
  312.           is  NOT compiled.   However,  if the loaded  text  redefines
  313.           modules  used by the load text routine,  unexpected  results
  314.           can occur.  Be especially careful about naming modules {UP},
  315.           {EDIT},  tilde,  and {ABORT}. If these modules are redefined
  316.           by  the  text being loaded in,  the text load will not  work
  317.           properly.
  318.  
  319.      R - renames  the  local module.   Renaming the ROOT  module  will
  320.           change the name {SAVE} uses when saving the Fifth system.
  321.  
  322.      S - saves  the  local  module and all  sub-modules  in  a  format
  323.           suitable  for text editors or listing.   This format may  be
  324.           used  in  conjunction  with  the L key to  upgrade  a  Fifth
  325.           program to a higher version number.
  326.  
  327.      T - toggles the trace mode on or off.   Trace "ON" allows  single
  328.           stepping  of Fifth  modules.  See {TRACE} in the  primitives
  329.           section in the manual or use the online help.
  330.  
  331.      X - compiles the local module if nessecary, then strips text from
  332.           the module and all children of the module.  This may be used
  333.           to free memory when the module will not need recompiling.
  334.  
  335.  
  336.                              -- The Text Editor --
  337.  
  338.      The text editor is invoked by the module {EDIT} or from the local
  339.      dictionary editor, {DIR}.  Upon exiting the editor,  the compiler
  340.      is  invoked.  Thus the  Fifth  compiler,  or  any  other compiler
  341.      implemented under Fifth, is incremental. Parts of the program are
  342.      compiled separately. This gives fast edit-compile-run turn around.
  343.  
  344.      The  Fifth  module editor is simple.  Only the  most  basic  text
  345.      editing functions are provided.  Fifth modules are normally quite
  346.      small,  thus a simple editor is normally sufficient. In Fifth the
  347.      program  structure  is edited using the dictionary  editor,  thus
  348.      providing block operations on functional boundries.
  349.  
  350.      The system editor is a very simple full screen text editor.   The
  351.      following is a summary of the key definitions in the editor.
  352.  
  353.                     ARROW right/left - Move the cursor right/left
  354.                                        one character.
  355.  
  356.                        ARROW up/down - Move the cursor up/down
  357.                                        one line.
  358.  
  359.              PAGE up/down (IBM PC)
  360.                      or
  361.            ALT ARROW up/down (TI PC) - page up/down.
  362.  
  363.        CONTROL PAGE up/down (IBM PC)
  364.                      or
  365.          SHIFT ARROW up/down (TI PC) - Drag line up/down.
  366.  
  367.                                   F1 - Insert line.
  368.  
  369.                                   F9 - Split line.
  370.  
  371.                     CONTROL Y and F7 - Delete line.
  372.  
  373.                                   F8 - Undelete line.
  374.  
  375.                                  F10 - Merge line.
  376.  
  377.                                  INS - Toggle insert/replace mode.
  378.                                        The cursor is half height with
  379.                                        replace mode, full height with
  380.                                        insert mode.
  381.  
  382.                    CONTROL G and DEL - Delete a character.
  383.  
  384.                                  TAB - Tab.
  385.  
  386.                            SHIFT TAB - Back tab.
  387.  
  388.                            CONTROL W - Toggle word wrap.
  389.  
  390.                               -- Disk I/O --
  391.  
  392.      Disk I/O is through MSDOS 2.00 extended disk I/O calls.   Instead
  393.      of a FCB,  a 16 bit file handle uniquely identifies the file.  If
  394.      old-style I/O is required,  the catch-all module INT allows a DOS
  395.      interupt to be used.
  396.  
  397.      All  I/O  calls are subject to error,  this is indicated  by  the
  398.      error flag and code.   The error code is returned by DOS and  may
  399.      be found in a DOS manual.
  400.  
  401.